<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>透明的单例类的编写优化版</title>
</head>
<body>
<script>
    // 使用闭包封装私有变量
var user = (function () {
    var _name = 'save',
        _age = 29;
    return {
        getUserInfo(){
            return _name + '-' + _age;
        }
    }
})();

console.log(user.getUserInfo());
</script>
</body>
</html>